﻿<!DOCTYPE HTML>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8">
    <title>g2geojson Tests</title>
    <link type="text/css" rel="stylesheet" href="http://yui.yahooapis.com/3.2.0/build/cssfonts/fonts-min.css" />
    <script type="text/javascript" src="http://yui.yahooapis.com/3.2.0/build/yui/yui-min.js"></script>
    <script type="text/javascript" src="../js/yuitest-core-min.js"></script>
    <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
    <script type="text/javascript" src="../js/g2geojson.js"></script>
    <style type="text/css">
        .yui3-skin-sam .yui3-console-entry-pass .yui3-console-entry-cat
        {
            background-color: green;
            color: #fff;
        }
        
        .yui3-skin-sam .yui3-console-entry-fail .yui3-console-entry-cat
        {
            background-color: red;
            color: #fff;
        }
        
        .yui3-skin-sam .yui3-console-entry-ignore .yui3-console-entry-cat
        {
            background-color: #666;
        }
    </style>
    <body class="yui3-skin-sam  yui-skin-sam">
        <h1>g2geojson</h1>
        <p>Tests</p>
        <div id="testLogger"></div>
        <script type="text/javascript">
			round = function(number, decimalPlaces) {
				if (!(decimalPlaces.constructor === Number))
					throw 'A numeric argument was expected';
				if (!decimalPlaces)
					return Math.round(decimalPlaces);
				temp = Math.pow(10, decimalPlaces);
				return Math.round(number*temp)/temp;
			};
			
            YUI().use("console", function (Y) {

                var isArray_TestCase = new YUITest.TestCase({
                    //--------------------------------
                    //Setup and TearDown
                    //--------------------------------
                    name: "isArray",
                    setUp: function () {
                        this.target = new g2geojson();
                    },
                    tearDown: function () {
                        delete this.target;
                    },
                    _should: {
                        error: {
                    }
                },

                //---------------------------------
                //Tests
                //---------------------------------
                testNumber: function () {
                    result = this.target.isArray(17.37);
                    YUITest.Assert.areEqual(false, result);
                },
                testObjectLiteral: function () {
                    result = this.target.isArray({});
                    YUITest.Assert.areEqual(false, result);
                },
                testArrayLiteral: function () {
                    result = this.target.isArray([]);
                    YUITest.Assert.areEqual(true, result);
                },
                testArrayNew: function () {
                    result = this.target.isArray(new Array());
                    YUITest.Assert.areEqual(true, result);
                }
            });

            var getPointGeoJson_TestCase = new YUITest.TestCase({
                //--------------------------------
                //Setup and TearDown
                //--------------------------------
                name: "getPointGeoJson",
                setUp: function () {
                    this.target = new g2geojson();
                },
                tearDown: function () {
                    delete this.target;
                },
                _should: {
                    error: {
                        "four arguments should fail": true,
                        "array with four items should fail": true,
                        "random object argument should fail": true
                    }
                },

                //---------------------------------
                //Tests
                //---------------------------------
                "lat and lng arguments should succeed": function () {
                    result = this.target.getPointGeoJson(17.37, 78.47);
                    YUITest.Assert.areEqual("Point", result['type']);
					YUITest.Assert.isArray(result['coordinates']);
					YUITest.Assert.areEqual(2, result['coordinates'].length);
					YUITest.Assert.areEqual(78.47, result['coordinates'][0]);
					YUITest.Assert.areEqual(17.37, result['coordinates'][1]);
                },
                "lat, lng and alt arguments should succeed": function () {
                    result = this.target.getPointGeoJson(17.45, 78.55, 2.3);
                    YUITest.Assert.areEqual("Point", result['type']);
					YUITest.Assert.isArray(result['coordinates']);
					YUITest.Assert.areEqual(3, result['coordinates'].length);
					YUITest.Assert.areEqual(78.55, result['coordinates'][0]);
					YUITest.Assert.areEqual(17.45, result['coordinates'][1]);
					YUITest.Assert.areEqual(2.3, result['coordinates'][2]);
                },
                "four arguments should fail": function () {
                    result = this.target.getPointGeoJson(17.56, 78.33, 4.5, 3.4);
                },
                "no arguments should return NULL": function () {
                    result = this.target.getPointGeoJson();
                    YUITest.Assert.isNull( result);
                },
                "array with lat and lng items should succeed": function () {
                    result = this.target.getPointGeoJson([17.37, 78.47]);
                    YUITest.Assert.areEqual("Point", result['type']);
					YUITest.Assert.isArray(result['coordinates']);
					YUITest.Assert.areEqual(2, result['coordinates'].length);
					YUITest.Assert.areEqual(78.47, result['coordinates'][0]);
					YUITest.Assert.areEqual(17.37, result['coordinates'][1]);
                },
                "array with lat, lng and alt items should succeed": function () {
                    result = this.target.getPointGeoJson([17.45, 78.55, 2.3]);
                    YUITest.Assert.areEqual("Point", result['type']);
					YUITest.Assert.isArray(result['coordinates']);
					YUITest.Assert.areEqual(3, result['coordinates'].length);
					YUITest.Assert.areEqual(78.55, result['coordinates'][0]);
					YUITest.Assert.areEqual(17.45, result['coordinates'][1]);
					YUITest.Assert.areEqual(2.3, result['coordinates'][2]);
                },
                "array with four items should fail": function () {
                    result = this.target.getPointGeoJson([17.56, 78.33, 4.5, 3.4]);
                },
                "google LatLng object argument should succeed": function () {
                    result = this.target.getPointGeoJson(new google.maps.LatLng(17.37, 78.47));
                    YUITest.Assert.areEqual("Point", result['type']);
					YUITest.Assert.isArray(result['coordinates']);
					YUITest.Assert.areEqual(2, result['coordinates'].length);
					YUITest.Assert.areEqual(78.47, round(result['coordinates'][0], 2));
					YUITest.Assert.areEqual(17.37, round(result['coordinates'][1], 2));
                },
                "random object argument should fail": function () {
                    result = this.target.getPointGeoJson({ 'some': 78.47, "test": 17.37 });
                }
            });


            var getLineGeoJson_TestCase = new YUITest.TestCase({
                //--------------------------------
                //Setup and TearDown
                //--------------------------------
                name: "getLineGeoJson",
                setUp: function () {
                    this.target = new g2geojson();
                },
                tearDown: function () {
                    delete this.target;
                },
                _should: {
                    error: {
                }
            },

            //---------------------------------
            //Tests
            //---------------------------------
            "MVCArray of LatLngs should succeed": function () {
                var ll1 = new google.maps.LatLng(17.37, 78.47);
                var ll2 = new google.maps.LatLng(17.55, 78.21);
                var ll3 = new google.maps.LatLng(17.15, 78.73);
                var data = new google.maps.MVCArray([ll1, ll2, ll3]);
                result = this.target.getLineGeoJson(data);
                YUITest.Assert.areEqual('LineString', result['type']);
				YUITest.Assert.isArray(result['coordinates']);
				YUITest.Assert.areEqual(3, result['coordinates'].length);
				YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0], 2));
				YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][1], 2));
				YUITest.Assert.areEqual(78.21, round(result['coordinates'][1][0], 2));
				YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][1], 2));
				YUITest.Assert.areEqual(78.73, round(result['coordinates'][2][0], 2));
				YUITest.Assert.areEqual(17.15, round(result['coordinates'][2][1], 2));
            },
            "array of LatLngs should succeed": function () {
                var ll1 = new google.maps.LatLng(17.37, 78.47);
                var ll2 = new google.maps.LatLng(17.55, 78.21);
                var ll3 = new google.maps.LatLng(17.15, 78.73);
                var data = [ll1, ll2, ll3];
                result = this.target.getLineGeoJson(data);
                YUITest.Assert.areEqual('LineString', result['type']);
				YUITest.Assert.isArray(result['coordinates']);
				YUITest.Assert.areEqual(3, result['coordinates'].length);
				YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0], 2));
				YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][1], 2));
				YUITest.Assert.areEqual(78.21, round(result['coordinates'][1][0], 2));
				YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][1], 2));
				YUITest.Assert.areEqual(78.73, round(result['coordinates'][2][0], 2));
				YUITest.Assert.areEqual(17.15, round(result['coordinates'][2][1], 2));
            },
            "getPath value from Polyline should succeed": function () {
                var ll1 = new google.maps.LatLng(17.37, 78.47);
                var ll2 = new google.maps.LatLng(17.55, 78.21);
                var ll3 = new google.maps.LatLng(17.15, 78.73);
                var data = new google.maps.Polyline({ 'path': [ll1, ll2, ll3] });
                result = this.target.getLineGeoJson(data.getPath());
                YUITest.Assert.areEqual('LineString', result['type']);
				YUITest.Assert.isArray(result['coordinates']);
				YUITest.Assert.areEqual(3, result['coordinates'].length);
				YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0], 2));
				YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][1], 2));
				YUITest.Assert.areEqual(78.21, round(result['coordinates'][1][0], 2));
				YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][1], 2));
				YUITest.Assert.areEqual(78.73, round(result['coordinates'][2][0], 2));
				YUITest.Assert.areEqual(17.15, round(result['coordinates'][2][1], 2));
            }
        });

        var getPolygonGeoJson_TestCase = new YUITest.TestCase({
            //--------------------------------
            //Setup and TearDown
            //--------------------------------
            name: "getPolygonGeoJson",
            setUp: function () {
                this.target = new g2geojson();
            },
            tearDown: function () {
                delete this.target;
            },
            _should: {
                error: {
            }
        },

        //---------------------------------
        //Tests
        //---------------------------------
        "an array of paths should succeed": function () {
            var ll1 = new google.maps.LatLng(17.37, 78.47);
            var ll2 = new google.maps.LatLng(17.55, 78.21);
            var ll3 = new google.maps.LatLng(17.15, 78.73);
            var ll4 = new google.maps.LatLng(17.35, 78.33);
            var ll5 = new google.maps.LatLng(17.25, 78.56);

            var hll1 = new google.maps.LatLng(17.47, 78.17);
            var hll2 = new google.maps.LatLng(17.35, 78.11);
            var hll3 = new google.maps.LatLng(17.55, 78.53);
            var hll4 = new google.maps.LatLng(17.25, 78.43);
            var hll5 = new google.maps.LatLng(17.65, 78.46);

            result = this.target.getPolygonGeoJson([[ll1, ll2, ll3, ll4, ll5], [hll1, hll2, hll3, hll4, hll5]]);
            YUITest.Assert.areEqual('Polygon', result['type']);
			YUITest.Assert.isArray(result['coordinates']);
			YUITest.Assert.areEqual(2, result['coordinates'].length);
			YUITest.Assert.areEqual(5, result['coordinates'][0].length);
			YUITest.Assert.areEqual(5, result['coordinates'][1].length);
			YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0][0], 2));
			YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][0][1], 2));
			YUITest.Assert.areEqual(78.21, round(result['coordinates'][0][1][0], 2));
			YUITest.Assert.areEqual(17.55, round(result['coordinates'][0][1][1], 2));
			YUITest.Assert.areEqual(78.73, round(result['coordinates'][0][2][0], 2));
			YUITest.Assert.areEqual(17.15, round(result['coordinates'][0][2][1], 2));
			YUITest.Assert.areEqual(78.33, round(result['coordinates'][0][3][0], 2));
			YUITest.Assert.areEqual(17.35, round(result['coordinates'][0][3][1], 2));
			YUITest.Assert.areEqual(78.56, round(result['coordinates'][0][4][0], 2));
			YUITest.Assert.areEqual(17.25, round(result['coordinates'][0][4][1], 2));
			
			YUITest.Assert.areEqual(78.17, round(result['coordinates'][1][0][0], 2));
			YUITest.Assert.areEqual(17.47, round(result['coordinates'][1][0][1], 2));
			YUITest.Assert.areEqual(78.11, round(result['coordinates'][1][1][0], 2));
			YUITest.Assert.areEqual(17.35, round(result['coordinates'][1][1][1], 2));
			YUITest.Assert.areEqual(78.53, round(result['coordinates'][1][2][0], 2));
			YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][2][1], 2));
			YUITest.Assert.areEqual(78.43, round(result['coordinates'][1][3][0], 2));
			YUITest.Assert.areEqual(17.25, round(result['coordinates'][1][3][1], 2));
			YUITest.Assert.areEqual(78.46, round(result['coordinates'][1][4][0], 2));
			YUITest.Assert.areEqual(17.65, round(result['coordinates'][1][4][1], 2));
        },
        "an MVCArray of paths should succeed": function () {
            var ll1 = new google.maps.LatLng(17.37, 78.47);
            var ll2 = new google.maps.LatLng(17.55, 78.21);
            var ll3 = new google.maps.LatLng(17.15, 78.73);
            var ll4 = new google.maps.LatLng(17.35, 78.33);
            var ll5 = new google.maps.LatLng(17.25, 78.56);

            var hll1 = new google.maps.LatLng(17.47, 78.17);
            var hll2 = new google.maps.LatLng(17.35, 78.11);
            var hll3 = new google.maps.LatLng(17.55, 78.53);
            var hll4 = new google.maps.LatLng(17.25, 78.43);
            var hll5 = new google.maps.LatLng(17.65, 78.46);

            var mvcarr = new google.maps.MVCArray([[ll1, ll2, ll3, ll4, ll5], [hll1, hll2, hll3, hll4, hll5]]);
            result = this.target.getPolygonGeoJson(mvcarr);
            YUITest.Assert.areEqual('Polygon', result['type']);
			YUITest.Assert.isArray(result['coordinates']);
			YUITest.Assert.areEqual(2, result['coordinates'].length);
			YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0][0], 2));
			YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][0][1], 2));
			YUITest.Assert.areEqual(78.21, round(result['coordinates'][0][1][0], 2));
			YUITest.Assert.areEqual(17.55, round(result['coordinates'][0][1][1], 2));
			YUITest.Assert.areEqual(78.73, round(result['coordinates'][0][2][0], 2));
			YUITest.Assert.areEqual(17.15, round(result['coordinates'][0][2][1], 2));
			YUITest.Assert.areEqual(78.33, round(result['coordinates'][0][3][0], 2));
			YUITest.Assert.areEqual(17.35, round(result['coordinates'][0][3][1], 2));
			YUITest.Assert.areEqual(78.56, round(result['coordinates'][0][4][0], 2));
			YUITest.Assert.areEqual(17.25, round(result['coordinates'][0][4][1], 2));
			
			YUITest.Assert.areEqual(78.17, round(result['coordinates'][1][0][0], 2));
			YUITest.Assert.areEqual(17.47, round(result['coordinates'][1][0][1], 2));
			YUITest.Assert.areEqual(78.11, round(result['coordinates'][1][1][0], 2));
			YUITest.Assert.areEqual(17.35, round(result['coordinates'][1][1][1], 2));
			YUITest.Assert.areEqual(78.53, round(result['coordinates'][1][2][0], 2));
			YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][2][1], 2));
			YUITest.Assert.areEqual(78.43, round(result['coordinates'][1][3][0], 2));
			YUITest.Assert.areEqual(17.25, round(result['coordinates'][1][3][1], 2));
			YUITest.Assert.areEqual(78.46, round(result['coordinates'][1][4][0], 2));
			YUITest.Assert.areEqual(17.65, round(result['coordinates'][1][4][1], 2));
        },
        "getPaths value from Polygon should succeed": function () {
            var ll1 = new google.maps.LatLng(17.37, 78.47);
            var ll2 = new google.maps.LatLng(17.55, 78.21);
            var ll3 = new google.maps.LatLng(17.15, 78.73);
            var ll4 = new google.maps.LatLng(17.35, 78.33);
            var ll5 = new google.maps.LatLng(17.25, 78.56);

            var hll1 = new google.maps.LatLng(17.47, 78.17);
            var hll2 = new google.maps.LatLng(17.35, 78.11);
            var hll3 = new google.maps.LatLng(17.55, 78.53);
            var hll4 = new google.maps.LatLng(17.25, 78.43);
            var hll5 = new google.maps.LatLng(17.65, 78.46);

            var poly = new google.maps.Polygon({ 'paths': [[ll1, ll2, ll3, ll4, ll5], [hll1, hll2, hll3, hll4, hll5]] });
            result = this.target.getPolygonGeoJson(poly.getPaths());
            YUITest.Assert.areEqual('Polygon', result['type']);
			YUITest.Assert.isArray(result['coordinates']);
			YUITest.Assert.areEqual(2, result['coordinates'].length);
			YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0][0], 2));
			YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][0][1], 2));
			YUITest.Assert.areEqual(78.21, round(result['coordinates'][0][1][0], 2));
			YUITest.Assert.areEqual(17.55, round(result['coordinates'][0][1][1], 2));
			YUITest.Assert.areEqual(78.73, round(result['coordinates'][0][2][0], 2));
			YUITest.Assert.areEqual(17.15, round(result['coordinates'][0][2][1], 2));
			YUITest.Assert.areEqual(78.33, round(result['coordinates'][0][3][0], 2));
			YUITest.Assert.areEqual(17.35, round(result['coordinates'][0][3][1], 2));
			YUITest.Assert.areEqual(78.56, round(result['coordinates'][0][4][0], 2));
			YUITest.Assert.areEqual(17.25, round(result['coordinates'][0][4][1], 2));
			
			YUITest.Assert.areEqual(78.17, round(result['coordinates'][1][0][0], 2));
			YUITest.Assert.areEqual(17.47, round(result['coordinates'][1][0][1], 2));
			YUITest.Assert.areEqual(78.11, round(result['coordinates'][1][1][0], 2));
			YUITest.Assert.areEqual(17.35, round(result['coordinates'][1][1][1], 2));
			YUITest.Assert.areEqual(78.53, round(result['coordinates'][1][2][0], 2));
			YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][2][1], 2));
			YUITest.Assert.areEqual(78.43, round(result['coordinates'][1][3][0], 2));
			YUITest.Assert.areEqual(17.25, round(result['coordinates'][1][3][1], 2));
			YUITest.Assert.areEqual(78.46, round(result['coordinates'][1][4][0], 2));
			YUITest.Assert.areEqual(17.65, round(result['coordinates'][1][4][1], 2));
        }
    });

    var getOverlayGeoJson_TestCase = new YUITest.TestCase({
        //--------------------------------
        //Setup and TearDown
        //--------------------------------
        name: "getOverlayGeoJson",
        setUp: function () {
            this.target = new g2geojson();
        },
        tearDown: function () {
            delete this.target;
        },
        _should: {
            error: {
        }
    },

    //---------------------------------
    //Tests
    //---------------------------------
    "marker argument should succeed": function () {
        var position = new google.maps.LatLng(17.37, 78.22);
        var marker = new google.maps.Marker({ 'position': position });
        result = this.target.getOverlayGeoJson(marker);
        YUITest.Assert.areEqual("Point", result['type']);
		YUITest.Assert.isArray(result['coordinates']);
		YUITest.Assert.areEqual(2, result['coordinates'].length);
		YUITest.Assert.areEqual(78.22, round(result['coordinates'][0], 2));
		YUITest.Assert.areEqual(17.37, round(result['coordinates'][1], 2));
    },
    "polyline argument should succeed": function () {
        var ll1 = new google.maps.LatLng(17.37, 78.47);
        var ll2 = new google.maps.LatLng(17.55, 78.21);
        var ll3 = new google.maps.LatLng(17.15, 78.73);
        var data = new google.maps.Polyline({ 'path': [ll1, ll2, ll3] });
        result = this.target.getOverlayGeoJson(data);
        YUITest.Assert.areEqual('LineString', result['type']);
		YUITest.Assert.isArray(result['coordinates']);
		YUITest.Assert.areEqual(3, result['coordinates'].length);
		YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0], 2));
		YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][1], 2));
		YUITest.Assert.areEqual(78.21, round(result['coordinates'][1][0], 2));
		YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][1], 2));
		YUITest.Assert.areEqual(78.73, round(result['coordinates'][2][0], 2));
		YUITest.Assert.areEqual(17.15, round(result['coordinates'][2][1], 2));
    },
    "polygon argument should succeed": function () {
        var ll1 = new google.maps.LatLng(17.37, 78.47);
        var ll2 = new google.maps.LatLng(17.55, 78.21);
        var ll3 = new google.maps.LatLng(17.15, 78.73);
        var ll4 = new google.maps.LatLng(17.35, 78.33);
        var ll5 = new google.maps.LatLng(17.25, 78.56);

        var hll1 = new google.maps.LatLng(17.47, 78.17);
        var hll2 = new google.maps.LatLng(17.35, 78.11);
        var hll3 = new google.maps.LatLng(17.55, 78.53);
        var hll4 = new google.maps.LatLng(17.25, 78.43);
        var hll5 = new google.maps.LatLng(17.65, 78.46);

        var poly = new google.maps.Polygon({ 'paths': [[ll1, ll2, ll3, ll4, ll5], [hll1, hll2, hll3, hll4, hll5]] });
        result = this.target.getOverlayGeoJson(poly);
        YUITest.Assert.areEqual('Polygon', result['type']);
		YUITest.Assert.isArray(result['coordinates']);
		YUITest.Assert.areEqual(2, result['coordinates'].length);
		YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0][0], 2));
		YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][0][1], 2));
		YUITest.Assert.areEqual(78.21, round(result['coordinates'][0][1][0], 2));
		YUITest.Assert.areEqual(17.55, round(result['coordinates'][0][1][1], 2));
		YUITest.Assert.areEqual(78.73, round(result['coordinates'][0][2][0], 2));
		YUITest.Assert.areEqual(17.15, round(result['coordinates'][0][2][1], 2));
		YUITest.Assert.areEqual(78.33, round(result['coordinates'][0][3][0], 2));
		YUITest.Assert.areEqual(17.35, round(result['coordinates'][0][3][1], 2));
		YUITest.Assert.areEqual(78.56, round(result['coordinates'][0][4][0], 2));
		YUITest.Assert.areEqual(17.25, round(result['coordinates'][0][4][1], 2));
		
		YUITest.Assert.areEqual(78.17, round(result['coordinates'][1][0][0], 2));
		YUITest.Assert.areEqual(17.47, round(result['coordinates'][1][0][1], 2));
		YUITest.Assert.areEqual(78.11, round(result['coordinates'][1][1][0], 2));
		YUITest.Assert.areEqual(17.35, round(result['coordinates'][1][1][1], 2));
		YUITest.Assert.areEqual(78.53, round(result['coordinates'][1][2][0], 2));
		YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][2][1], 2));
		YUITest.Assert.areEqual(78.43, round(result['coordinates'][1][3][0], 2));
		YUITest.Assert.areEqual(17.25, round(result['coordinates'][1][3][1], 2));
		YUITest.Assert.areEqual(78.46, round(result['coordinates'][1][4][0], 2));
		YUITest.Assert.areEqual(17.65, round(result['coordinates'][1][4][1], 2));
    },
    "an array of overlays argument should succeed": function () {
        var position = new google.maps.LatLng(17.37, 78.22);
        var marker = new google.maps.Marker({ 'position': position });

        var ll1 = new google.maps.LatLng(17.37, 78.47);
        var ll2 = new google.maps.LatLng(17.55, 78.21);
        var ll3 = new google.maps.LatLng(17.15, 78.73);
        var line = new google.maps.Polyline({ 'path': [ll1, ll2, ll3] });

        var sll1 = new google.maps.LatLng(17.37, 78.47);
        var sll2 = new google.maps.LatLng(17.55, 78.21);
        var sll3 = new google.maps.LatLng(17.15, 78.73);
        var sll4 = new google.maps.LatLng(17.35, 78.33);
        var sll5 = new google.maps.LatLng(17.25, 78.56);

        var hll1 = new google.maps.LatLng(17.47, 78.17);
        var hll2 = new google.maps.LatLng(17.35, 78.11);
        var hll3 = new google.maps.LatLng(17.55, 78.53);
        var hll4 = new google.maps.LatLng(17.25, 78.43);
        var hll5 = new google.maps.LatLng(17.65, 78.46);

        var poly = new google.maps.Polygon({ 'paths': [[sll1, sll2, sll3, sll4, sll5], [hll1, hll2, hll3, hll4, hll5]] });

        output = this.target.getOverlayGeoJson([marker,line,poly]);
        YUITest.Assert.areEqual('GeometryCollection', output['type']);
		YUITest.Assert.isArray(output['geometries']);

		var result = output['geometries'][0];
		YUITest.Assert.areEqual("Point", result['type']);
		YUITest.Assert.isArray(result['coordinates']);
		YUITest.Assert.areEqual(2, result['coordinates'].length);
		YUITest.Assert.areEqual(78.22, round(result['coordinates'][0], 2));
		YUITest.Assert.areEqual(17.37, round(result['coordinates'][1], 2));
		
		var result = output['geometries'][1];
		YUITest.Assert.areEqual('LineString', result['type']);
		YUITest.Assert.isArray(result['coordinates']);
		YUITest.Assert.areEqual(3, result['coordinates'].length);
		YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0], 2));
		YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][1], 2));
		YUITest.Assert.areEqual(78.21, round(result['coordinates'][1][0], 2));
		YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][1], 2));
		YUITest.Assert.areEqual(78.73, round(result['coordinates'][2][0], 2));
		YUITest.Assert.areEqual(17.15, round(result['coordinates'][2][1], 2));
		
		var result = output['geometries'][2];
		YUITest.Assert.areEqual('Polygon', result['type']);
		YUITest.Assert.isArray(result['coordinates']);
		YUITest.Assert.areEqual(2, result['coordinates'].length);
		YUITest.Assert.areEqual(78.47, round(result['coordinates'][0][0][0], 2));
		YUITest.Assert.areEqual(17.37, round(result['coordinates'][0][0][1], 2));
		YUITest.Assert.areEqual(78.21, round(result['coordinates'][0][1][0], 2));
		YUITest.Assert.areEqual(17.55, round(result['coordinates'][0][1][1], 2));
		YUITest.Assert.areEqual(78.73, round(result['coordinates'][0][2][0], 2));
		YUITest.Assert.areEqual(17.15, round(result['coordinates'][0][2][1], 2));
		YUITest.Assert.areEqual(78.33, round(result['coordinates'][0][3][0], 2));
		YUITest.Assert.areEqual(17.35, round(result['coordinates'][0][3][1], 2));
		YUITest.Assert.areEqual(78.56, round(result['coordinates'][0][4][0], 2));
		YUITest.Assert.areEqual(17.25, round(result['coordinates'][0][4][1], 2));
		
		YUITest.Assert.areEqual(78.17, round(result['coordinates'][1][0][0], 2));
		YUITest.Assert.areEqual(17.47, round(result['coordinates'][1][0][1], 2));
		YUITest.Assert.areEqual(78.11, round(result['coordinates'][1][1][0], 2));
		YUITest.Assert.areEqual(17.35, round(result['coordinates'][1][1][1], 2));
		YUITest.Assert.areEqual(78.53, round(result['coordinates'][1][2][0], 2));
		YUITest.Assert.areEqual(17.55, round(result['coordinates'][1][2][1], 2));
		YUITest.Assert.areEqual(78.43, round(result['coordinates'][1][3][0], 2));
		YUITest.Assert.areEqual(17.25, round(result['coordinates'][1][3][1], 2));
		YUITest.Assert.areEqual(78.46, round(result['coordinates'][1][4][0], 2));
		YUITest.Assert.areEqual(17.65, round(result['coordinates'][1][4][1], 2));
    }
});


var suite = new YUITest.TestSuite("g2kml Test Suite");
suite.add(isArray_TestCase);
suite.add(getPointGeoJson_TestCase);
suite.add(getLineGeoJson_TestCase);
suite.add(getPolygonGeoJson_TestCase);
suite.add(getOverlayGeoJson_TestCase);

//create the console
var r = new Y.Console({
    newestOnTop: false,
    style: 'block' // to anchor in the example content
});

r.render('#testLogger');

var TestRunner = YUITest.TestRunner;

TestRunner.add(suite);


//function to handle events generated by the testrunner
function logEvent(event) {

    //data variables
    var message = "",
            messageType = "";

    switch (event.type) {
        case TestRunner.BEGIN_EVENT:
            message = "Testing began at " + (new Date()).toString() + ".";
            messageType = "info";
            break;

        case TestRunner.COMPLETE_EVENT:
            message = Y.substitute("Testing completed at " +
                    (new Date()).toString() + ".\n" +
                    "Passed:{passed} Failed:{failed} " +
                    "Total:{total} ({ignored} ignored)",
                    event.results);
            messageType = "info";
            break;

        case TestRunner.TEST_FAIL_EVENT:
            message = event.testName + ": failed.\n" + event.error.getMessage();
            messageType = "fail";
            break;

        case TestRunner.TEST_IGNORE_EVENT:
            message = event.testName + ": ignored.";
            messageType = "ignore";
            break;

        case TestRunner.TEST_PASS_EVENT:
            message = event.testName + ": passed.";
            messageType = "pass";
            break;

        case TestRunner.TEST_SUITE_BEGIN_EVENT:
            message = "Test suite \"" + event.testSuite.name + "\" started.";
            messageType = "info";
            break;

        case TestRunner.TEST_SUITE_COMPLETE_EVENT:
            message = Y.substitute("Test suite \"" +
                    event.testSuite.name + "\" completed" + ".\n" +
                    "Passed:{passed} Failed:{failed} " +
                    "Total:{total} ({ignored} ignored)",
                    event.results);
            messageType = "info";
            break;

        case TestRunner.TEST_CASE_BEGIN_EVENT:
            message = "Test case \"" + event.testCase.name + "\" started.";
            messageType = "info";
            break;

        case TestRunner.TEST_CASE_COMPLETE_EVENT:
            message = Y.substitute("Test case \"" +
                    event.testCase.name + "\" completed.\n" +
                    "Passed:{passed} Failed:{failed} " +
                    "Total:{total} ({ignored} ignored)",
                    event.results);
            messageType = "info";
            break;
        default:
            message = "Unexpected event " + event.type;
            message = "info";
    }

    //only log if required
    Y.log(message, messageType, "TestRunner");
}

//listen for events to publish to the logger
TestRunner.attach(TestRunner.BEGIN_EVENT, logEvent);
TestRunner.attach(TestRunner.COMPLETE_EVENT, logEvent);
TestRunner.attach(TestRunner.TEST_CASE_BEGIN_EVENT, logEvent);
TestRunner.attach(TestRunner.TEST_CASE_COMPLETE_EVENT, logEvent);
TestRunner.attach(TestRunner.TEST_SUITE_BEGIN_EVENT, logEvent);
TestRunner.attach(TestRunner.TEST_SUITE_COMPLETE_EVENT, logEvent);
TestRunner.attach(TestRunner.TEST_PASS_EVENT, logEvent);
TestRunner.attach(TestRunner.TEST_FAIL_EVENT, logEvent);
TestRunner.attach(TestRunner.TEST_IGNORE_EVENT, logEvent);


//run the tests
TestRunner.run();

});
        </script>
    </body>
</html>
